LVS + Keepalived #2
2013/08/20 |
It's Redundant configuration for LVS + Keepalived Server itself.
| +----------------+----------------+ | | 192.168.0.100|eth0 ----VIP:192.168.0.99--- eth0|192.168.0.101 +----------------+ +----------------+ | LVS+Keepalived | | LVS+Keepalived | +----------------+ +----------------+ 10.0.0.100|eth1 -----VIP:10.0.0.99----- eth1|10.0.0.101 | | +----------------+----------------+ | +----------+ | +----------+ | |10.0.0.30 | 10.0.0.31| | | Backend1 |------------------------------| Backend2 | | Web | eth0 eth0| Web | +----------+ +----------+ |
Please change the default gateway to internal VIP address of Keepalived Server on both Backend Web Servers first.
(it's 10.0.0.99 on this example)
|
|
[1] | Clear the LVS settings first because it is controled by Keepalived. |
[root@gw ~]# ipvsadm -C [root@gw ~]# /etc/rc.d/init.d/ipvsadm save ipvsadm: Saving IPVS table to /etc/sysconfig/ipvsadm: [ OK ] |
[2] | Configure Keepalived It's OK to set the same settings except one setting on both backend servers. (it's "priority" section. Change it on both backend server.) |
[root@gw ~]# mv /etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf.bk
[root@gw ~]#
vi /etc/keepalived/keepalived.conf # create new global_defs { notification_email { cent@srv.world } notification_email_from root@srv.world smtp_server 127.0.0.1 smtp_connect_timeout 30 router_id LVS_Server } vrrp_instance VI_1 { state BACKUP interface eth0 virtual_router_id 51 # priority (change it on both servers) priority 100 advert_int 1 # authentication information between Keepalived servers authentication { auth_type PASS auth_pass password } virtual_ipaddress { # virtual IP address 192.168.0.99 dev eth0 10.0.0.99 dev eth1 } } virtual_server 192.168.0.99 80 { delay_loop 3 lvs_sched rr lvs_method NAT protocol TCP real_server 10.0.0.30 80 { weight 1 HTTP_GET { url { path / status_code 200 } connect_timeout 3 } } real_server 10.0.0.31 80 { weight 1 HTTP_GET { url { path / status_code 200 } connect_timeout 3 } } } /etc/rc.d/init.d/keepalived restart Stopping keepalived: [ OK ] Starting keepalived: [ OK ] |
[3] |
It's OK all. Access to the Service IP address and make sure it works normally.
|